<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet"/>
<link href="assets/css/front/listCommonStyle.css" rel="stylesheet"/>
<link href="assets/css/modify.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<div class="row margin-left-10">
	<!-- 映射列表 -->
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<div class="widget flat margin-top-0" style="margin: -10px 0 0px 0!important;">
			<div class="widget-header bordered-sky theme-bordered nopadding">
				<div class="widget-buttons widget-label nomargin-bottom">
					<label class="businessBtns">
						<ol class="breadcrumb" style="margin: 0;">
							<li style="color: #809fa6;">基础设置</li>
							<li class="active" style="color: #23a8f5;">学期设置</li>
						</ol>
					</label>
				</div>
			</div>
		</div>
	</div>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<div class="widget flat searchCriteria " style="margin: 3px 0 0px 0!important;padding-bottom: 10px">
			<div class="widget-header bordered-sky theme-bordered nopadding">
				<div class="widget-buttons widget-label nomargin-bottom">
					<label class="businessBtns">
						<a type="btn" class="btn basicInfoBtn" href="javascript:toView('tssSemesterController/tssSemesterList.do',true,'POST',{pageSize:10})"
						   style="background-color: #23a8f5;border: none;border-radius: 4px!important;width: 140px;color: #fff;margin-right: 0!important;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
							学期设置
						</a>
					</label>
					<label class="pull-right businessBtns">
						<label class="margin-right-10">
							<a class="btn btn-warning shiny add" serializeNum="${serializeNum}" targetDateId="" onclick="showDialogAddSemester(this)" style="border-radius: 0px;border: none;background: #ffab00  !important;">
								<i class="fa fa-plus"></i>新增学期
							</a>
						</label>
						<label class="margin-right-10">
							<a style="border-radius: 0px;border: none;background: #23a8f5 !important;"
							   class="btn btn-blue shiny download" onclick="exportData('${searchFormId}','MemberInformation.xlsx')"><i class="fa fa-share"></i>导出
							</a>
						</label>
						<label class="margin-right-10">
							<a style="border-radius: 0px;border: none;background: #ffab00 !important;"
							   class="btn btn-warning shiny search "><i class="fa fa-search"></i>搜索
							</a>
						</label>
					</label>
				</div>
			</div>
		</div>
		<div class="search_Bar" style="vertical-align: middle;clear: both;">
			<form id="${searchFormId}" action="${actionUrl}" class="searchConditions" method="POST">
				<div class="row searchInput" style="margin: 0;">
					<label class="iconchange1 hidden" style="position: absolute;right: 10px;top: 50px;" >
						<a class="search_Bar_A" id="iconchangemore" style="color: #2a6496;cursor: pointer;" onclick="iconchangeShow(this)" value="1">筛选更多<i class="fa fa-chevron-down" style="padding-left: 5px"></i></a>
					</label>
					<label style="margin-bottom: 15px;margin-right: 40px;" class="search_Bar_item hidden">
						<label style="width: 78px">所属年份：</label>
						<label>
							<select class="form-select-1 particularYear" value="${search_map.particularYear[0]}"
									style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;"
									name="particularYear" id="particularYear">
							</select>
						</label>
					</label>
				</div>
			</form>
		</div>
		<div class="widget flat radius-bordered" style="margin-top: 0;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
			<div class="widget-body no-padding">
				<div class="topPagingBar hidden">
					${pagingBar}
				</div>
				<div class="table-scrollable" style="border: none;" id="tableScrollable">
					<!-- 数据表列信息列表 -->
					<table class="table table-hover dataTable newtable">
						<thead>
						<tr>
							<th title="选择" class="checkboxColumnTh">
								<div class="checkbox">
									<label>
										<input type="checkbox" class="chkAll" onclick="chkAll()">
										<span class="text"></span>
									</label>
								</div>
							</th>
							<th title="属性名">序号</th>
							<th>操作项</th>
							<th title="年份">年份</th>
							<th title="学期类型">学期类型</th>
							<th title="学期时间段">学期时间段</th>
							<th title="创建人">创建人</th>
							<th title="创建日期">创建日期</th>
						</tr>
						</thead>
						<tbody>
						<#if page_bean.list?size==0>
							<tr>
								<td align="center">无数据</td>
							</tr>
						</#if>
						<#list page_bean.list as data>
							<tr>
								<td class="checkboxColumnTd">
									<div class="checkbox">
										<label>
											<input type="checkbox" class="chk" name="id" value="${data.id}">
											<span class="text"></span>
										</label>
									</div>
								</td>
								<td>${data_index+1+(page_bean.pageNo-1)*page_bean.pageSize}</td>
								<td align="center">
									<a style="color: #2679B8" class="margin-right-10" title="编辑" href="javascript:void(0);" onclick="showDialogAddSemester(this)"
									   serializeNum="${serializeNum}"  targetDateId="${data.id}">修改</a>
								</td>
								<td>${(data.particularYear???string(data.particularYear?html,""))!''}</td>
								<td><@dictionary groupCode="semesterType" dictionaryCode="${data.type}" ;semesterType>${semesterType.value }</@dictionary></td>
								<td>${(data.startDate???string(data.startDate?string("yyyy-MM-dd"),""))!''} - ${(data.endDate???string(data.endDate?string("yyyy-MM-dd"),""))!''}</td>
								<td>${(data.sysAdminUser.realName???string(data.sysAdminUser.realName?html,""))!''}</td>
								<td>${(data.createTime???string(data.createTime?html,""))!''}</td>
							</tr>
						</#list>
						</tbody>
					</table>
				</div>
				${pagingBar}
			</div>
		</div>
	</div>
</div>
<script>
    $(".selectpicker").select2();


    /**
     * 创建亲子课程
     * @param that
     */
    function showDialogAddSemester(that) {
        var serializeNum = $(that).attr("serializeNum");
        var targetDateId = $(that).attr("targetDateId");
        ajaxRequest("tssSemesterController/toEditView.do", {
            serializeNum: serializeNum,
            targetDateId:targetDateId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                className:"myDialog tssSemesterEdit"
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
            $(".modal-body>button").hide();
        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")

    }

    /**
     * 全选反选
     * */
    function chkAll(){
        var ids;
        $("[name='id']").each(function(){
            if($(this).attr("checked", true)){
                $(this).attr("checked", false);
            } else{
                $(this).attr("checked", true);
            }
        });
    }

    /**
     * 导出数据
     * @param formId 条件表单id
     * @param templateName 导出的文件名
     */
    function exportData(formId, templateName) {
        var ids = "";
        $("[name='id']:checked").each(function(){
            ids += "," +$(this).val();
        });
        ids = ids.substring(1);

        var params = $("#" + formId).serialize();
        var exportIframe = ' <iframe class="hidden" id="exportIframe" name="exportIframe"></iframe>';
        var exportSrc ="tssClassRoomController/exportExcle.do";
        var $exportForm = $('<form method="post" target="exportIframe" action="' + exportSrc + '" id="exportForm"></form>');
        $("#" + formId).find("input").map(function (i, input) {
            var $input = $(input);
            var name = $input.attr("name");
            var val = $input.val();
            if (name) {
                $exportForm.append('<input type="hidden" name="' + name + '" value="' + val + '">');
            }
        });

        //追加参数
        $exportForm.append('<input type="hidden" name="ids" value="'+ids+'">');
        $exportForm.append('<input type="hidden" name="templateName" value="' + templateName + '">');
        $exportForm.append('<input type="hidden" name="loginAdminUserId" value="${loginUserId}">');

        //删除并提交表单
        $("body #exportIframe").remove();
        $("body #exportForm").remove();
        $("body").append(exportIframe);
        $("body").append($exportForm);
        $exportForm.submit();
    };


    //    隐藏显示搜索
    function iconsChange() {
        if($(".iconsChangeA").val()==1){
            $(".iconsChangeA").val("0");
            $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_hidden.png')");
            $(".iconsChangeSpan").html("隐藏搜索栏");
            $(".search_Bar").removeClass("hidden");
        }else{
            $(".iconsChangeA").val("1");
            $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_show.png')");
            $(".iconsChangeSpan").html("显示搜索栏");
            $(".search_Bar").addClass("hidden");
        }
    }

    //    筛选下拉框
    setTimeout(function () {
        var size = $(".search_Bar_item").size();
        if (size > 8) {
            $(".iconchange1").removeClass("hidden");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                }

            })
        } else {
            $(".iconchange1").addClass("hidden");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        }

    }, 10)

    function iconchangeShow(that) {

        if($(that).attr("value")==1){
            $(that).attr("value","0");
            $(".iconchange1 .fa").removeClass("fa-chevron-down").addClass("fa-chevron-up");
            $(".search_Bar_item").each(function () {
                $(this).removeClass("hidden")
            })
        }else{
            $(that).attr("value","1");
            $(".iconchange1 .fa").removeClass("fa-chevron-up").addClass("fa-chevron-down");
            $(".search_Bar_item").each(function () {
                var index = $(this).index();
                if (index <= 8) {
                    $(this).removeClass("hidden")
                }else{
                    $(this).addClass("hidden")
                }

            })
        }

    }
    $(function () {
        var data = $("#particularYear").attr("value")
        var arr = ['<option value="">请选择</option>'];
        for (var i = 2017; i <= 2037; i++) {
            if(i == data){
                arr.push('<option value="' + i + '" selected="selected">' + i + '</option>')
            } else {
                arr.push('<option value="' + i + '">' + i + '</option>')
            }

        }
        $("#particularYear").html(arr.join(''))
    });


</script>